﻿using DimensionsHelper.Serialization.Enumerator;

namespace DimensionsHelper.LanguageService.Syntax;

[AttributeUsage(AttributeTargets.Field)]
public class TokenAttribute(string text) : EnumStringAttribute(text)
{
}


[AttributeUsage(AttributeTargets.Field)]
public class PunctuationAttribute(PunctuationContexts context) : Attribute
{
    public PunctuationContexts Context { get; } = context;
}


[Flags]
public enum OperatorKind
{
    Unary = 0x1,
    Binary = 0x2,
    Both = Unary | Binary, // - 用作负号时，视作一元操作符
    Logical = 0x4,
    Compute = 0x8,
    Compare = 0x10
}


[AttributeUsage(AttributeTargets.Field)]
public class OperatorAttribute : Attribute
{
    public int Priority { get; set; } = 0;

    public OperatorContexts Context { get; set; } = OperatorContexts.Script;

    public OperatorKind Kind { get; set; } = OperatorKind.Binary;
}


[AttributeUsage(AttributeTargets.Field)]
public class KeywordAttribute(string text, KeywordContexts section) : TokenAttribute(text)
{
    public KeywordContexts Section { get; set; } = section;
}


[AttributeUsage(AttributeTargets.Field)]
public class ModifierAttribute(string text, KeywordContexts section) : KeywordAttribute(text, section)
{
}